package seo.main;

import seo.database.DataBase;
import seo.location.SEOLocationProvider;
import android.app.Application;
import android.content.Context;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationManager;

public class SeoApplication extends Application {
	
	private SEOLocationProvider locationProvider;
	private Location lastKnownLocation = null;
	private String lastKnownLocationAddress = null;
	private DataBase dataBase;
	
	@Override
	public void onCreate() {
		super.onCreate();
		this.dataBase = new DataBase(this);
		this.startLocationProvider();
		locationProvider.start();
	}

	public void startLocationProvider() {
		LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
		Geocoder gc = new Geocoder(this);
		locationProvider = new SEOLocationProvider(locationManager, gc,lastKnownLocation,lastKnownLocationAddress);
	}
		
	public SEOLocationProvider getLocationProvider(){
		return locationProvider;
	}
	
	public void setLastKnownLocation(Location newLocation){
		this.lastKnownLocation = newLocation;
	}
	
	public void setLastKnownLocationAddress(String newLocationAddress){
		this.lastKnownLocationAddress = newLocationAddress;
	}
	
	public String getLastKnownLocationAddress(){
		return this.lastKnownLocationAddress;
	}
	
	public DataBase getDataBase(){
		return this.dataBase;
	}
	
}